/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_RTSP_HEADEDER_H
#define MK_RTSP_HEADEDER_H
#include "MkUtil/MkTypes.h"

//https://datatracker.ietf.org/doc/html/rfc2326#section-12.39
class MkApi CMkRtspTransport
{
public:
    CMkRtspTransport();
    ~CMkRtspTransport() {}

    Uint32 ParseClientTransport(const MkString& Content);
    Uint32 ParseServerTransport(const MkString& Content);
    Uint32 ParseRtpInfo(const MkString& RtpInfo);
    Uint32 ToClientTransportString(OUT MkString& Content) const;
    Uint32 ToServerTransportString(OUT MkString& Content) const;

    const MkString& GetTransport() const { return m_Transport; }
    const MkString& GetProfile()const { return m_Profile; }
    const MkString& GetLowTransport()const { return m_LowerTransport; }
    const BOOL& IsUnicast()const { return m_bUnicast; }
    const MkString& GetDestincation() const { return m_Destincation; }
    const MkString& GetSource()const { return m_Source; }
    const Uint32& GetLayers()const { return m_Layers; }
    const MkString& GetMode()const { return m_Mode; }
    const MkString& GetAppend()const { return m_Append; }
    const Uint32& GetRtpInterleaved()const { return m_RtpInterleaved; }
    const Uint32& GetRtcpInterleaved() const { return m_RtcpInterleaved; }
    const Uint32& GetTtl()const { return m_Ttl; }
    const Uint16& GetRtpPort()const { return m_RtpPort; }
    const Uint16& GetClientRtpPort()const { return m_ClientRtpPort; }
    const Uint16& GetClientRtcpPort() const { return m_ClientRtcpPort; }
    const Uint16& GetServerRtpPort()const { return m_ServerRtpPort; }
    const Uint16& GetServerRtcpPort()const { return m_ServerRtcpPort; }
    const Uint32& GetSsrc()const { return m_Ssrc; }
    const Uint16& GetSeq()const { return m_Seq; }
    const Uint32& GetTimeStamp() const { return m_TimeStamp; }

    void SetLowTransport(const MkString& LowTransport) { m_LowerTransport = LowTransport; }
    void SetUnicast(BOOL bUnicast) { m_bUnicast = bUnicast; }
    void SetDestincation(const MkString& Dest) { m_Destincation = Dest; }
    void SetSource(const MkString& Source) { m_Source; }
    void SetLayers(Uint32 Layers) { m_Layers = Layers; }
    void SetMode(const MkString& Mode) { m_Mode = Mode; }
    void SetAppend(const MkString& Append) { m_Append = Append; }
    void SetRtpInterleaved(Uint32 Interleaved) { m_RtpInterleaved = Interleaved; }
    void SetRtcpInterleaved(Uint32 Interleaved) { m_RtcpInterleaved = Interleaved; }
    void SetTtl(Uint32 Ttl) { m_Ttl = Ttl; }
    void SetRtpPort(Uint16 Port) { m_RtpPort = Port; }
    void SetClientRtpPort(Uint16 Port) { m_ClientRtpPort = Port; }
    void SetClientRtcpPort(Uint16 Port) { m_ClientRtcpPort = Port; }
    void SetServerRtpPort(Uint16 Port) { m_ServerRtpPort = Port; }
    void SetServerRtcpPort(Uint16 Port) { m_ServerRtcpPort = Port; }
    void SetSsrc(Uint32 Ssrc) { m_Ssrc = Ssrc; }
    void SetSeq(Uint16 Seq) { m_Seq = Seq; }
    void SetRtpTime(Uint32 TimeStamp) { m_TimeStamp = TimeStamp; }
protected:
private:
    Uint32 ParseParamItem(const MkString& Item);
private:
    MkString	m_Transport;        //always  rtp
    MkString	m_Profile;          //always  avp
    MkString	m_LowerTransport;   //udp or tcp
    BOOL		m_bUnicast;         //otherwise muticast
    MkString	m_Destincation;     //dst host
    MkString	m_Source;			//source host
    Uint32		m_Layers;           //tansport layers
    MkString	m_Mode;             //PLAY or RECORD  default PLAY
    MkString	m_Append;	        //record used
    Uint32		m_RtpInterleaved;   //rtp interleaved
    Uint32      m_RtcpInterleaved;  //rtcp interleaved
    Uint32		m_Ttl;              //multicast time to live
    Uint16   	m_RtpPort;          //multicast use
    Uint16   	m_ClientRtpPort;    //udp rtp port
    Uint16      m_ClientRtcpPort;   //udp rtcp port
    Uint16		m_ServerRtpPort;    //server rtp port
    Uint16      m_ServerRtcpPort;   //server rtcp port
    Uint32		m_Ssrc;
    Uint16      m_Seq;
    Uint32      m_TimeStamp;
};


#endif



